<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="./">
<head>
  <meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>iso8601 &mdash; Logtalk APIs v3.93.0-b01 documentation</title>
      <link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d75fae25" />
      <link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=19f00094" />
      <link rel="stylesheet" type="text/css" href="_static/css/custom.css?v=0e9007aa" />

  
  <!--[if lt IE 9]>
    <script src="_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
        <script src="_static/jquery.js?v=5d32c60e"></script>
        <script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
        <script src="_static/documentation_options.js?v=c8100655"></script>
        <script src="_static/doctools.js?v=9a2dae69"></script>
        <script src="_static/sphinx_highlight.js?v=dc90522c"></script>
    <script src="_static/js/theme.js"></script>
    <!-- begin favicon -->
    <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
    <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
    <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
    <link rel="manifest" href="/site.webmanifest" />
    <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5" />
    <meta name="msapplication-TileColor" content="#355b95" />
    <meta name="theme-color" content="#ffffff" />
    <!-- end favicon -->
    
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="issue_creator" href="issue_creator_0.html" />
    <link rel="prev" title="intervalp" href="intervalp_0.html" />
   
</head>

<body class="wy-body-for-nav"> 
  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >

          
          
          <a href="index.html" class="icon icon-home">
            Logtalk APIs
              <img src="_static/logtalk.gif" class="logo" alt="Logo"/>
          </a>
              <div class="version">
                3.93.0
              </div>
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
        </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
    
              <p class="caption" role="heading"><span class="caption-text">Contents</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="library_index.html">Libraries</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="library_index.html#arbitrary"><span class="xref std std-ref">arbitrary</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#assertions"><span class="xref std std-ref">assertions</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#assignvars"><span class="xref std std-ref">assignvars</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#base64"><span class="xref std std-ref">base64</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#cbor"><span class="xref std std-ref">cbor</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#code-metrics"><span class="xref std std-ref">code_metrics</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#core"><span class="xref std std-ref">core</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#coroutining"><span class="xref std std-ref">coroutining</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#csv"><span class="xref std std-ref">csv</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#dates"><span class="xref std std-ref">dates</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#dead-code-scanner"><span class="xref std std-ref">dead_code_scanner</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#debug-messages"><span class="xref std std-ref">debug_messages</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#debugger"><span class="xref std std-ref">debugger</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#dependents"><span class="xref std std-ref">dependents</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#diagrams"><span class="xref std std-ref">diagrams</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#dictionaries"><span class="xref std std-ref">dictionaries</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#dif"><span class="xref std std-ref">dif</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#doclet"><span class="xref std std-ref">doclet</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#edcg"><span class="xref std std-ref">edcg</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#events"><span class="xref std std-ref">events</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#expand-library-alias-paths"><span class="xref std std-ref">expand_library_alias_paths</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#expecteds"><span class="xref std std-ref">expecteds</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#fcube"><span class="xref std std-ref">fcube</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#flags"><span class="xref std std-ref">flags</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#format"><span class="xref std std-ref">format</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#genint"><span class="xref std std-ref">genint</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#gensym"><span class="xref std std-ref">gensym</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#git"><span class="xref std std-ref">git</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#grammars"><span class="xref std std-ref">grammars</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#heaps"><span class="xref std std-ref">heaps</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#help"><span class="xref std std-ref">help</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#hierarchies"><span class="xref std std-ref">hierarchies</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#hook-flows"><span class="xref std std-ref">hook_flows</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#hook-objects"><span class="xref std std-ref">hook_objects</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#html"><span class="xref std std-ref">html</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#ids"><span class="xref std std-ref">ids</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#intervals"><span class="xref std std-ref">intervals</span></a></li>
<li class="toctree-l2 current"><a class="reference internal" href="library_index.html#iso8601"><span class="xref std std-ref">iso8601</span></a><ul class="current">
<li class="toctree-l3 current"><a class="current reference internal" href="#">iso8601</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#issue-creator"><span class="xref std std-ref">issue_creator</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#java"><span class="xref std std-ref">java</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#json"><span class="xref std std-ref">json</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#json-lines"><span class="xref std std-ref">json_lines</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#lgtdoc"><span class="xref std std-ref">lgtdoc</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#lgtunit"><span class="xref std std-ref">lgtunit</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#library"><span class="xref std std-ref">library</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#listing"><span class="xref std std-ref">listing</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#logging"><span class="xref std std-ref">logging</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#loops"><span class="xref std std-ref">loops</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#meta"><span class="xref std std-ref">meta</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#meta-compiler"><span class="xref std std-ref">meta_compiler</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#metagol"><span class="xref std std-ref">metagol</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#mutations"><span class="xref std std-ref">mutations</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#nested-dictionaries"><span class="xref std std-ref">nested_dictionaries</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#optionals"><span class="xref std std-ref">optionals</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#options"><span class="xref std std-ref">options</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#os"><span class="xref std std-ref">os</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#packs"><span class="xref std std-ref">packs</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#pddl-parser"><span class="xref std std-ref">pddl_parser</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#ports-profiler"><span class="xref std std-ref">ports_profiler</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#queues"><span class="xref std std-ref">queues</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#random"><span class="xref std std-ref">random</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#reader"><span class="xref std std-ref">reader</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#recorded-database"><span class="xref std std-ref">recorded_database</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#redis"><span class="xref std std-ref">redis</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#sets"><span class="xref std std-ref">sets</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#statistics"><span class="xref std std-ref">statistics</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#term-io"><span class="xref std std-ref">term_io</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#timeout"><span class="xref std std-ref">timeout</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#toychr"><span class="xref std std-ref">toychr</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#tsv"><span class="xref std std-ref">tsv</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#tutor"><span class="xref std std-ref">tutor</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#types"><span class="xref std std-ref">types</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#ulid"><span class="xref std std-ref">ulid</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#union-find"><span class="xref std std-ref">union_find</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#uuid"><span class="xref std std-ref">uuid</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#verdi-neruda"><span class="xref std std-ref">verdi_neruda</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#wrapper"><span class="xref std std-ref">wrapper</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#xml-parser"><span class="xref std std-ref">xml_parser</span></a></li>
<li class="toctree-l2"><a class="reference internal" href="library_index.html#zippers"><span class="xref std std-ref">zippers</span></a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="directory_index.html">Directories</a></li>
<li class="toctree-l1"><a class="reference internal" href="entity_index.html">Entities</a></li>
<li class="toctree-l1"><a class="reference internal" href="predicate_index.html">Predicates</a></li>
</ul>

    <ul>
    <li class="toctree-l1"><a class="reference internal" href="core_inheritance_diagram.svg">Core diagram</a></li>
    <li class="toctree-l1"><a class="reference internal" href="library_inheritance_diagram.svg">Libraries diagram</a></li>
    <li class="toctree-l1"><a class="reference internal" href="tools_inheritance_diagram.svg">Tools diagram</a></li>
    <li class="toctree-l1"><a class="reference internal" href="ports_inheritance_diagram.svg">Ports diagram</a></li>
    <li class="toctree-l1"><a class="reference internal" href="contributions_inheritance_diagram.svg">Contributions diagram</a></li>
    <li class="toctree-l1"><a class="reference internal" href="genindex.html">Index</a></li>
    </ul>
    <p class="caption"><span class="caption-text">External Contents</span></p>
    <ul>
    <li class="toctree-l1"><a class="reference internal" href="../handbook/index.html">Handbook</a></li>
    <li class="toctree-l1"><a class="reference internal" href="https://logtalk.org">Logtalk website</a></li>
    <li class="toctree-l1"><a class="reference internal" href="https://github.com/LogtalkDotOrg/logtalk3">GitHub repo</a></li>
    </ul>
  
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">Logtalk APIs</a>
      </nav>

      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="index.html" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="library_index.html">Libraries</a></li>
      <li class="breadcrumb-item active"><code class="docutils literal notranslate"><span class="pre">iso8601</span></code></li>
      <li class="wy-breadcrumbs-aside">
            <a href="_sources/iso8601_0.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             
  <p class="right" id="iso8601-0"><span id="index-0"></span><strong>object</strong></p>
<section id="iso8601">
<h1><code class="docutils literal notranslate"><span class="pre">iso8601</span></code><a class="headerlink" href="#iso8601" title="Link to this heading"></a></h1>
<p>ISO 8601 (and European civil calendar) compliant library of date predicates.</p>
<div class="line-block">
<div class="line"><strong>Availability:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">logtalk_load(iso8601(loader))</span></code></div>
</div>
</div>
<div class="line-block">
<div class="line"><strong>Author:</strong> Daniel L. Dudley</div>
<div class="line"><strong>Version:</strong> 1:0:3</div>
<div class="line"><strong>Date:</strong> 2019-10-09</div>
</div>
<div class="line-block">
<div class="line"><strong>Compilation flags:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">static,</span> <span class="pre">context_switching_calls</span></code></div>
</div>
</div>
<div class="line-block">
<div class="line"><strong>Uses:</strong></div>
<div class="line-block">
<div class="line"><a class="reference internal" href="os_0.html#os-0"><span class="std std-ref">os</span></a></div>
</div>
</div>
<div class="line-block">
<div class="line"><strong>Remarks:</strong></div>
</div>
<blockquote>
<div><ul class="simple">
<li><p>Scope: This object currently provides a powerful, versatile and efficient set of date-handling predicates, which–thanks to Logtalk–may be used as is on a wide range of Prolog compilers. Besides taking time to familiarize oneself with each predicate, the user should take note of the following information.</p></li>
<li><p>Validation of dates: Date parts are not validated–that is the caller’s responsibility! However, not being quite heartless yet, we do provide a predicate for this purpose.</p></li>
<li><p>Date arithmetic: Many of the examples illustrate a simplified method of doing date arithmetic. Note, however, that we do not generally recommend this practice–it is all too easy to make mistakes. The safest way of finding the day difference between two dates is to first convert the dates to their Julian day numbers and then subtract one from the other. Similarly, the safe way to add or subtract a day offset to a particular date is to first convert the date to its Julian day number, add or subtract the day offset, and then convert the result to its corresponding date.</p></li>
<li><p>BC years: ISO 8601 specifies that the Gregorian calendar be used, yet requires that years prior to 1 AD be handled arithmetically, i.e., the year we know as 1 BC is year 0, 2 BC is year -1, 3 BC is year -2 and so on. We do not follow ISO 8601 with regard to the handling of BC years. Our date predicates will accept and interpret an input year 0 as 1 BC; however, a negative year, Year, should always be interpreted as <code class="docutils literal notranslate"><span class="pre">abs(Year)</span> <span class="pre">=:=</span> <span class="pre">Year</span> <span class="pre">BC</span></code>. We believe that the average person will find our handling of BC years more user-friendly than the ISO 8601 one, but we encourage feedback from users with a view to a possible change in future versions.</p></li>
<li><p>Week numbers: It is possible for a day (date) to have a week number that belongs to another year. Up to three of the first days of a calendar year may belong to the last week (number) of the prior calendar year, and up to three days of the last days of a calendar year may belong to the first week (number) of the next calendar year. It for this reason that the Week parameter in <code class="docutils literal notranslate"><span class="pre">date/6-7</span></code> is a compound term, namely <code class="docutils literal notranslate"><span class="pre">week(WeekNo,ActualYear)</span></code>.</p></li>
<li><p>Computation of Gregorian Easter Sunday: The algorithm is based upon the “Gaussian rule”. Proleptic use is limited to years &gt; 1582 AD, that is, after the introduction of the Gregorian calendar.</p></li>
<li><p>Some Christian feast day offsets from Easter Sunday: Carnival Monday: -48 days, Mardi Gras (Shrove Tuesday): -47 days, Ash Wednesday: -46 days, Palm Sunday: -7 days, Easter Friday: -2 days, Easter Saturday: -1 day, Easter Monday: +1 day, Ascension of Christ: +39 days, Whitsunday: +49 days, Whitmonday: +50 days, Feast of Corpus Christi: +60 days.</p></li>
</ul>
</div></blockquote>
<div class="line-block">
<div class="line"><strong>Inherited public predicates:</strong></div>
<div class="line-block">
<div class="line">(none)</div>
</div>
</div>
<nav class="contents local" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#public-predicates" id="id1">Public predicates</a></p>
<ul>
<li><p><a class="reference internal" href="#date-4" id="id2"><code class="docutils literal notranslate"><span class="pre">date/4</span></code></a></p></li>
<li><p><a class="reference internal" href="#date-5" id="id3"><code class="docutils literal notranslate"><span class="pre">date/5</span></code></a></p></li>
<li><p><a class="reference internal" href="#date-6" id="id4"><code class="docutils literal notranslate"><span class="pre">date/6</span></code></a></p></li>
<li><p><a class="reference internal" href="#date-7" id="id5"><code class="docutils literal notranslate"><span class="pre">date/7</span></code></a></p></li>
<li><p><a class="reference internal" href="#date-string-3" id="id6"><code class="docutils literal notranslate"><span class="pre">date_string/3</span></code></a></p></li>
<li><p><a class="reference internal" href="#valid-date-3" id="id7"><code class="docutils literal notranslate"><span class="pre">valid_date/3</span></code></a></p></li>
<li><p><a class="reference internal" href="#leap-year-1" id="id8"><code class="docutils literal notranslate"><span class="pre">leap_year/1</span></code></a></p></li>
<li><p><a class="reference internal" href="#calendar-month-3" id="id9"><code class="docutils literal notranslate"><span class="pre">calendar_month/3</span></code></a></p></li>
<li><p><a class="reference internal" href="#easter-day-3" id="id10"><code class="docutils literal notranslate"><span class="pre">easter_day/3</span></code></a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#protected-predicates" id="id11">Protected predicates</a></p></li>
<li><p><a class="reference internal" href="#private-predicates" id="id12">Private predicates</a></p></li>
<li><p><a class="reference internal" href="#operators" id="id13">Operators</a></p></li>
</ul>
</nav>
<section id="public-predicates">
<h2><a class="toc-backref" href="#contents" role="doc-backlink">Public predicates</a><a class="headerlink" href="#public-predicates" title="Link to this heading"></a></h2>
<section id="date-4">
<span id="iso8601-0-date-4"></span><span id="index-1"></span><h3><a class="toc-backref" href="#contents" role="doc-backlink"><code class="docutils literal notranslate"><span class="pre">date/4</span></code></a><a class="headerlink" href="#date-4" title="Link to this heading"></a></h3>
<p>Get the system date and/or its Julian Day # or convert a Julian Day # to/from given date parts.</p>
<div class="line-block">
<div class="line"><strong>Compilation flags:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">static</span></code></div>
</div>
</div>
<div class="line-block">
<div class="line"><strong>Template:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(JD,Year,Month,Day)</span></code></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">JD</span></code> - Julian day serial number.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Year</span></code> - 0 or negative if converted BC year, positive otherwise.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Month</span></code> - Normally an integer between 1 and 12 inclusive.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Day</span></code> - Normally an integer between 1 and 31 inclusive depending upon month.</div>
</div>
</div>
<div class="line"><strong>Mode and number of proofs:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(?integer,?integer,?integer,?integer)</span></code> - <code class="docutils literal notranslate"><span class="pre">zero_or_one</span></code></div>
</div>
</div>
<div class="line-block">
<div class="line"><strong>Examples:</strong></div>
<div class="line-block">
<div class="line">Current date (i.e., today)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(JD,Year,Month,Day)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">JD=2453471,Year=2005,Month=4,Day=10</span></code></div>
</div>
<div class="line">Convert a date to its Julian day number</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(JD,2000,2,29)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">JD=2451604</span></code></div>
</div>
<div class="line">Convert a Julian day number to its date</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(2451604,Year,Month,Day)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Year=2000,Month=2,Day=29</span></code></div>
</div>
<div class="line">What is the date of day # 60 in year 2000?</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(JD,2000,1,60)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">JD=2451604</span></code></div>
</div>
<div class="line">What is the Julian of the 1st day prior to 2000-1-1?</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(JD,2000,1,0)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">JD=2451544</span></code></div>
</div>
<div class="line">What is the Julian of the 60th day prior to 2000-1-1?</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(JD,2000,1,-59)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">JD=2451485</span></code></div>
</div>
<div class="line">Illegal date is auto-adjusted (see also next query)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(JD,1900,2,29)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">JD=2415080</span></code></div>
</div>
<div class="line">This is the correct date!</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(2415080,Year,Month,Day)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Year=1900,Month=3,Day=1</span></code></div>
</div>
</div>
</div>
<hr class="docutils" />
</section>
<section id="date-5">
<span id="iso8601-0-date-5"></span><span id="index-2"></span><h3><a class="toc-backref" href="#contents" role="doc-backlink"><code class="docutils literal notranslate"><span class="pre">date/5</span></code></a><a class="headerlink" href="#date-5" title="Link to this heading"></a></h3>
<p>Ditto <code class="docutils literal notranslate"><span class="pre">date/4</span></code> + get/check its day-of-week #.</p>
<div class="line-block">
<div class="line"><strong>Compilation flags:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">static</span></code></div>
</div>
</div>
<div class="line-block">
<div class="line"><strong>Template:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(JD,Year,Month,Day,DoW)</span></code></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">JD</span></code> - Julian day serial number.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Year</span></code> - 0 or negative if converted BC year, positive otherwise.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Month</span></code> - Normally an integer between 1 and 12 inclusive.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Day</span></code> - Normally an integer between 1 and 31 inclusive depending upon month.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">DoW</span></code> - Day of week, where Monday=1, Tuesday=2, …, Sunday=7.</div>
</div>
</div>
<div class="line"><strong>Mode and number of proofs:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(?integer,?integer,?integer,?integer,?integer)</span></code> - <code class="docutils literal notranslate"><span class="pre">zero_or_one</span></code></div>
</div>
</div>
<div class="line-block">
<div class="line"><strong>Examples:</strong></div>
<div class="line-block">
<div class="line">Get the Julian and the day-of-week # of a date</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(JD,2000,2,29,DoW)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">JD=2451604,DoW=2</span></code></div>
</div>
<div class="line">Check the validity of a given date (day-of-week is 2, not 4)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(_,2002,3,5,4)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">no</span></code></div>
</div>
<div class="line">Get the Julian day of a given date if it is a Sunday</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(JD,2004,2,29,7)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">JD=2453065</span></code></div>
</div>
<div class="line">Get the date and day-of-week # of a Julian</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(2451545,Year,Month,Day,DoW)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Year=2000,Month=1,Day=1,DoW=6</span></code></div>
</div>
</div>
</div>
<hr class="docutils" />
</section>
<section id="date-6">
<span id="iso8601-0-date-6"></span><span id="index-3"></span><h3><a class="toc-backref" href="#contents" role="doc-backlink"><code class="docutils literal notranslate"><span class="pre">date/6</span></code></a><a class="headerlink" href="#date-6" title="Link to this heading"></a></h3>
<p>Ditto <code class="docutils literal notranslate"><span class="pre">date/5</span></code> + get/check its week #.</p>
<div class="line-block">
<div class="line"><strong>Compilation flags:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">static</span></code></div>
</div>
</div>
<div class="line-block">
<div class="line"><strong>Template:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(JD,Year,Month,Day,DoW,Week)</span></code></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">JD</span></code> - Julian day serial number.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Year</span></code> - 0 or negative if converted BC year, positive otherwise.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Month</span></code> - Normally an integer between 1 and 12 inclusive.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Day</span></code> - Normally an integer between 1 and 31 inclusive depending upon month.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">DoW</span></code> - Day of week, where Monday=1, Tuesday=2, …, Sunday=7.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Week</span></code> - Compound term, <code class="docutils literal notranslate"><span class="pre">week(WeekNo,ActualYear)</span></code>, of a day.</div>
</div>
</div>
<div class="line"><strong>Mode and number of proofs:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(?integer,?integer,?integer,?integer,?integer,?compound)</span></code> - <code class="docutils literal notranslate"><span class="pre">zero_or_one</span></code></div>
</div>
</div>
<div class="line-block">
<div class="line"><strong>Examples:</strong></div>
<div class="line-block">
<div class="line">Get the day-of-week and week number of a date</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(_,2000,1,1,DoW,Week)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">DoW=6,Week=week(52,1999)</span></code></div>
</div>
<div class="line">Get the week number and year of this week</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(_,_,_,_,_,Week)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Week=week(7,2004)</span></code></div>
</div>
<div class="line">Get the Julian number and the week of a date if it is a Sunday</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(JD,2004,2,29,7,Week)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">JD=2453065,Week=week(9,2004)</span></code></div>
</div>
<div class="line">Get the day-of-week and week of a Julian day number</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(2453066,_,_,_,DoW,Week)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">DoW=1,Week=week(10,2004)</span></code></div>
</div>
<div class="line">Check that given date data matches</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(_,2004,3,1,1,week(10,2004))</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">yes</span></code></div>
</div>
<div class="line">What is the date of a day of week (default is 1) in given week # and year?</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(_,Year,Month,Day,DoW,week(26,2004))</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Year=2004,Month=6,Day=21,DoW=1</span></code></div>
</div>
<div class="line">Ditto for Sunday</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(_,Year,Month,Day,7,week(1,2005))</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Year=2005,Month=1,Day=9</span></code></div>
</div>
<div class="line">Ditto for Tuesday in following week</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(_,Year,Month,Day,9,week(1,2005))</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Year=2005,Month=1,Day=11</span></code></div>
</div>
<div class="line">Ditto for Thursday in the prior week</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(_,Year,Month,Day,4,week(0,2005))</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Year=2004,Month=12,Day=30</span></code></div>
</div>
<div class="line">Ditto for Tuesday two weeks prior</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(_,Year,Month,Day,2,week(-1,2005))</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Year=2004,Month=12,Day=21</span></code></div>
</div>
<div class="line">Ditto for Saturday</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(_,Year,Month,Day,6,week(53,2004))</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Year=2005,Month=1,Day=1</span></code></div>
</div>
<div class="line">Ditto for Monday (note automatic compensation of nonexistent week number)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(_,Year,Month,Day,1,week(60,2004))</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Year=2005,Month=2,Day=14</span></code></div>
</div>
</div>
</div>
<hr class="docutils" />
</section>
<section id="date-7">
<span id="iso8601-0-date-7"></span><span id="index-4"></span><h3><a class="toc-backref" href="#contents" role="doc-backlink"><code class="docutils literal notranslate"><span class="pre">date/7</span></code></a><a class="headerlink" href="#date-7" title="Link to this heading"></a></h3>
<p>Ditto <code class="docutils literal notranslate"><span class="pre">date/6</span></code> + get/check its day-of-year #.</p>
<div class="line-block">
<div class="line"><strong>Compilation flags:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">static</span></code></div>
</div>
</div>
<div class="line-block">
<div class="line"><strong>Template:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(JD,Year,Month,Day,DoW,Week,DoY)</span></code></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">JD</span></code> - Julian day serial number.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Year</span></code> - 0 or negative if converted BC year, positive otherwise.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Month</span></code> - Normally an integer between 1 and 12 inclusive.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Day</span></code> - Normally an integer between 1 and 31 inclusive depending upon month.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">DoW</span></code> - Day of week, where Monday=1, Tuesday=2, …, Sunday=7.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Week</span></code> - Compound term, <code class="docutils literal notranslate"><span class="pre">week(WeekNo,ActualYear)</span></code>, of a day.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">DoY</span></code> - Day of year (NB! calendar year, not week # year).</div>
</div>
</div>
<div class="line"><strong>Mode and number of proofs:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(?integer,?integer,?integer,?integer,?integer,?compound,?integer)</span></code> - <code class="docutils literal notranslate"><span class="pre">zero_or_one</span></code></div>
</div>
</div>
<div class="line-block">
<div class="line"><strong>Examples:</strong></div>
<div class="line-block">
<div class="line">Get the date and day-of-year of a Julian number</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(2451649,Year,Month,Day,_,_,DoY)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Year=2000,Month=4,Day=14,DoY=105</span></code></div>
</div>
<div class="line">Get the Julian number, week number and day-of-year of a date, confirming that it is a Sunday</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(JD,2004,2,29,7,Week,DoY)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">JD=2453065,Week=week(9,2004),DoY=60</span></code></div>
</div>
<div class="line">Confirm that a date is, in fact, a specific day-of-year</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(_,2004,3,1,_,_,61)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">yes</span></code></div>
</div>
<div class="line">Get the Julian number, week day and day-of-year of a date</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(JD,2004,10,18,DoW,_,DoY)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">JD=2453297,DoW=1,DoY=292</span></code></div>
</div>
<div class="line">Get today’s day-of-year</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(_,_,_,_,_,_,DoY)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">DoY=54</span></code></div>
</div>
<div class="line">Get all missing date data (excl. Julian number) for the 60th calendar day of 2004</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(_,2004,Month,Day,DoW,Week,60)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Month=2,Day=29,DoW=7,Week=week(9,2004)</span></code></div>
</div>
<div class="line">Match given date data and, if true, return the missing data (excl. Julian number)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(_,2004,3,Day,DoW,Week,61)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Day=1,DoW=1,Week=week(10,2004)</span></code></div>
</div>
<div class="line">Ditto (the 61st day-of-year cannot be both day 1 and 2 of the month)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date(_,2004,_,2,_,_,61)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">no</span></code></div>
</div>
</div>
</div>
<hr class="docutils" />
</section>
<section id="date-string-3">
<span id="iso8601-0-date-string-3"></span><span id="index-5"></span><h3><a class="toc-backref" href="#contents" role="doc-backlink"><code class="docutils literal notranslate"><span class="pre">date_string/3</span></code></a><a class="headerlink" href="#date-string-3" title="Link to this heading"></a></h3>
<p>Conversion between an ISO 8601 compliant date string and its components (truncated and expanded date representations are currently unsupported). Note that date components are not validated; that is the caller’s responsibility!</p>
<div class="line-block">
<div class="line"><strong>Compilation flags:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">static</span></code></div>
</div>
</div>
<div class="line-block">
<div class="line"><strong>Template:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string(Format,Components,String)</span></code></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">Format</span></code> - ISO 8601 format.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Components</span></code> - When bound and String is free, either a Julian number or a <code class="docutils literal notranslate"><span class="pre">[Year,Month,Day]</span></code> term; it binds to the system day/date if free When free and String is bound, it binds to an integer list representing the numeric elements of String.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">String</span></code> - ISO 8601 formatted string correspondent to Components.</div>
</div>
</div>
<div class="line"><strong>Mode and number of proofs:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string(+atom,+integer,?atom)</span></code> - <code class="docutils literal notranslate"><span class="pre">zero_or_one</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string(+atom,?list,?atom)</span></code> - <code class="docutils literal notranslate"><span class="pre">zero_or_one</span></code></div>
</div>
</div>
<div class="line-block">
<div class="line"><strong>Examples:</strong></div>
<div class="line-block">
<div class="line">Date, complete, basic (section 5.2.1.1)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYYMMDD',[2004,2,29],String)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">String='20040229'</span></code></div>
</div>
<div class="line">Date, complete, basic (section 5.2.1.1)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYYMMDD',Components,'20040229')</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Components=[2004,2,29]</span></code></div>
</div>
<div class="line">Date, complete, extended (section 5.2.1.1)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYY-MM-DD',[2003,12,16],String)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">String='2003-12-16'</span></code></div>
</div>
<div class="line">Date, complete, extended (section 5.2.1.1)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYY-MM-DD',Components,'2003-12-16')</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Components=[2003,12,16]</span></code></div>
</div>
<div class="line">Date, complete, extended (section 5.2.1.1)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYY-MM-DD',_,String)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">String='2004-02-17'</span></code></div>
</div>
<div class="line">Date, complete, extended (section 5.2.1.1)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYY-MM-DD',Components,'2004-02-17')</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Components=[2004,2,17]</span></code></div>
</div>
<div class="line">Date, reduced, month (section 5.2.1.2 a)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYY-MM',[2004,9,18],String)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">String='2004-09'</span></code></div>
</div>
<div class="line">Date, reduced, month (section 5.2.1.2 a)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYY-MM',Components,'2004-09')</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Components=[2004,9]</span></code></div>
</div>
<div class="line">Date, reduced, year (section 5.2.1.2 b)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYY',[1900,7,24],String)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">String='1900'</span></code></div>
</div>
<div class="line">Date, reduced, year (section 5.2.1.2 b)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYY',Components,'1900')</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Components=[1900]</span></code></div>
</div>
<div class="line">Date, reduced, century (section 5.2.1.2 c)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YY',2456557,String)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">String='20'</span></code></div>
</div>
<div class="line">Date, reduced, century (section 5.2.1.2 c)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YY',Components,'20')</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Components=[20]</span></code></div>
</div>
<div class="line">Date, ordinal, complete (section 5.2.2.1)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYYDDD',[2005,3,25],String)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">String='2005084'</span></code></div>
</div>
<div class="line">Date, ordinal, complete (section 5.2.2.1)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYYDDD',Components,'2005084')</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Components=[2005,84]</span></code></div>
</div>
<div class="line">Date, ordinal, extended (section 5.2.2.1)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYY-DDD',[1854,12,4],String)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">String='1854-338'</span></code></div>
</div>
<div class="line">Date, ordinal, extended (section 5.2.2.1)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYY-DDD',Components,'1854-338')</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Components=[1854,338]</span></code></div>
</div>
<div class="line">Week, complete, basic (section 5.2.3.1)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYYWwwD',[2000,1,2],String)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">String='1999W527'</span></code></div>
</div>
<div class="line">Week, complete, basic (section 5.2.3.1)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYYWwwD',Components,'1999W527')</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Components=[1999,52,7]</span></code></div>
</div>
<div class="line">Week, complete, extended (section 5.2.3.1)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYY-Www-D',[2003,12,29],String)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">String='2004-W01-1'</span></code></div>
</div>
<div class="line">Week, complete, extended (section 5.2.3.1)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYY-Www-D',Components,'2004-W01-1')</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Components=[2004,1,1]</span></code></div>
</div>
<div class="line">Week, complete, extended (section 5.2.3.1)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYY-Www-D',2453167,String)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">String='2004-W24-4'</span></code></div>
</div>
<div class="line">Week, complete, extended (section 5.2.3.1)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYY-Www-D',Components,'2004-W24-4')</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Components=[2004,24,4]</span></code></div>
</div>
<div class="line">Week, reduced, basic (section 5.2.3.2)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYYWww',[2004,2,29],String)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">String='2004W09'</span></code></div>
</div>
<div class="line">Week, reduced, basic (section 5.2.3.2)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYYWww',Components,'2004W09')</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Components=[2004,9]</span></code></div>
</div>
<div class="line">Week, reduced, extended (section 5.2.3.2)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYY-Www',[2004,2,29],String)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">String='2004-W09'</span></code></div>
</div>
<div class="line">Week, reduced, extended (section 5.2.3.2)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">date_string('YYYY-Www',Components,'2004-W09')</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Components=[2004,9]</span></code></div>
</div>
</div>
</div>
<hr class="docutils" />
</section>
<section id="valid-date-3">
<span id="iso8601-0-valid-date-3"></span><span id="index-6"></span><h3><a class="toc-backref" href="#contents" role="doc-backlink"><code class="docutils literal notranslate"><span class="pre">valid_date/3</span></code></a><a class="headerlink" href="#valid-date-3" title="Link to this heading"></a></h3>
<p>Validate a given date in the Gregorian calendar.</p>
<div class="line-block">
<div class="line"><strong>Compilation flags:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">static</span></code></div>
</div>
</div>
<div class="line-block">
<div class="line"><strong>Template:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">valid_date(Year,Month,Day)</span></code></div>
</div>
<div class="line"><strong>Mode and number of proofs:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">valid_date(+integer,+integer,+integer)</span></code> - <code class="docutils literal notranslate"><span class="pre">zero_or_one</span></code></div>
</div>
</div>
<div class="line-block">
<div class="line"><strong>Examples:</strong></div>
<div class="line-block">
<div class="line">Yes, the recent millennium was a leap year</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">valid_date(2000,2,29)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">yes</span></code></div>
</div>
<div class="line">2004 was also a leap year</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">valid_date(2004,2,29)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">yes</span></code></div>
</div>
<div class="line">Only 30 days in April</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">valid_date(2004,4,31)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">no</span></code></div>
</div>
<div class="line">1 BC was a leap year</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">valid_date(-1,2,29)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">yes</span></code></div>
</div>
</div>
</div>
<hr class="docutils" />
</section>
<section id="leap-year-1">
<span id="iso8601-0-leap-year-1"></span><span id="index-7"></span><h3><a class="toc-backref" href="#contents" role="doc-backlink"><code class="docutils literal notranslate"><span class="pre">leap_year/1</span></code></a><a class="headerlink" href="#leap-year-1" title="Link to this heading"></a></h3>
<p>Succeed if given year is a leap year in the Gregorian calendar.</p>
<div class="line-block">
<div class="line"><strong>Compilation flags:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">static</span></code></div>
</div>
</div>
<div class="line-block">
<div class="line"><strong>Template:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">leap_year(Year)</span></code></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">Year</span></code> - The Gregorian calendar year to investigate. If free, it binds to the system year.</div>
</div>
</div>
<div class="line"><strong>Mode and number of proofs:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">leap_year(?integer)</span></code> - <code class="docutils literal notranslate"><span class="pre">zero_or_one</span></code></div>
</div>
</div>
<div class="line-block">
<div class="line"><strong>Examples:</strong></div>
<div class="line-block">
<div class="line">No, the prior centenary was not a leap year</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">leap_year(1900)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">no</span></code></div>
</div>
<div class="line">The recent millennium</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">leap_year(2000)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">yes</span></code></div>
</div>
<div class="line">This year</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">leap_year(Year)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Year=2004</span></code></div>
</div>
<div class="line">This year (equivalent to prior query)</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">leap_year(_)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">yes</span></code></div>
</div>
<div class="line">Next centennial</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">leap_year(2100)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">no</span></code></div>
</div>
<div class="line">Year 0, equivalent to 1 BC</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">leap_year(0)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">yes</span></code></div>
</div>
<div class="line">1 BC</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">leap_year(-1)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">yes</span></code></div>
</div>
<div class="line">4 BC</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">leap_year(-4)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">no</span></code></div>
</div>
<div class="line">5 BC</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">leap_year(-5)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">yes</span></code></div>
</div>
</div>
</div>
<hr class="docutils" />
</section>
<section id="calendar-month-3">
<span id="iso8601-0-calendar-month-3"></span><span id="index-8"></span><h3><a class="toc-backref" href="#contents" role="doc-backlink"><code class="docutils literal notranslate"><span class="pre">calendar_month/3</span></code></a><a class="headerlink" href="#calendar-month-3" title="Link to this heading"></a></h3>
<p>Compute a calendar month.</p>
<div class="line-block">
<div class="line"><strong>Compilation flags:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">static</span></code></div>
</div>
</div>
<div class="line-block">
<div class="line"><strong>Template:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">calendar_month(Year,Month,Calendar)</span></code></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">Year</span></code> - The calendar year.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Month</span></code> - The calendar month.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Calendar</span></code> - A compound term, <code class="docutils literal notranslate"><span class="pre">m/3</span></code>, composed of three main arguments specifying year, month, and a list of week and week day numbers (calendar body).</div>
</div>
</div>
<div class="line"><strong>Mode and number of proofs:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">calendar_month(?integer,?integer,-compound)</span></code> - <code class="docutils literal notranslate"><span class="pre">zero_or_one</span></code></div>
</div>
</div>
<div class="line-block">
<div class="line"><strong>Examples:</strong></div>
<div class="line-block">
<div class="line">Compute the calendar of March, 2005</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">calendar_month(2005,3,Calendar)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Calendar=m(2005,3,[w(9,[0,1,2,3,4,5,6]),w(10,[7,8,9,10,11,12,13]),w(11,[14,15,16,17,18,19,20]),w(12,[21,22,23,24,25,26,27]),w(13,[28,29,30,31,0,0,0]),w(0,[0,0,0,0,0,0,0])])</span></code></div>
</div>
</div>
</div>
<hr class="docutils" />
</section>
<section id="easter-day-3">
<span id="iso8601-0-easter-day-3"></span><span id="index-9"></span><h3><a class="toc-backref" href="#contents" role="doc-backlink"><code class="docutils literal notranslate"><span class="pre">easter_day/3</span></code></a><a class="headerlink" href="#easter-day-3" title="Link to this heading"></a></h3>
<p>Compute a Gregorian Easter Sunday.</p>
<div class="line-block">
<div class="line"><strong>Compilation flags:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">static</span></code></div>
</div>
</div>
<div class="line-block">
<div class="line"><strong>Template:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">easter_day(Year,Month,Day)</span></code></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">Year</span></code> - Integer specifying the year to be investigated.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Month</span></code> - Month in which Easter Sunday falls for given year.</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Day</span></code> - Day of month in which Easter Sunday falls for given year.</div>
</div>
</div>
<div class="line"><strong>Mode and number of proofs:</strong></div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">easter_day(?integer,-integer,-integer)</span></code> - <code class="docutils literal notranslate"><span class="pre">zero_or_one</span></code></div>
</div>
</div>
<div class="line-block">
<div class="line"><strong>Examples:</strong></div>
<div class="line-block">
<div class="line">Compute Easter Sunday for a particular year</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">easter_day(2006,Month,Day)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Month=4,Day=16</span></code></div>
</div>
<div class="line">Compute Easter Sunday for the current year</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">easter_day(Year,Month,Day)</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Year=2005,Month=3,Day=27</span></code></div>
</div>
</div>
</div>
</section>
</section>
<hr class="docutils" />
<section id="protected-predicates">
<h2><a class="toc-backref" href="#contents" role="doc-backlink">Protected predicates</a><a class="headerlink" href="#protected-predicates" title="Link to this heading"></a></h2>
<p>(no local declarations; see entity ancestors if any)</p>
</section>
<section id="private-predicates">
<h2><a class="toc-backref" href="#contents" role="doc-backlink">Private predicates</a><a class="headerlink" href="#private-predicates" title="Link to this heading"></a></h2>
<p>(no local declarations; see entity ancestors if any)</p>
</section>
<section id="operators">
<h2><a class="toc-backref" href="#contents" role="doc-backlink">Operators</a><a class="headerlink" href="#operators" title="Link to this heading"></a></h2>
<p>(none)</p>
</section>
</section>


           </div>
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="intervalp_0.html" class="btn btn-neutral float-left" title="intervalp" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="issue_creator_0.html" class="btn btn-neutral float-right" title="issue_creator" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 1998-2025, Paulo Moura.</p>
  </div>

  Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    provided by <a href="https://readthedocs.org">Read the Docs</a>.
   

</footer>
        </div>
      </div>
    </section>
  </div>
  <script>
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>